package com.wb.web.backend;


import com.github.pagehelper.Page;
import com.wb.model.EbNews;
import com.wb.service.NewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller
@RequestMapping("/news")
public class NewsController {

    @Autowired
    private NewsService newsService;
    @RequestMapping("/list")
    public String lis(Model model,
                      @RequestParam(value = "page",defaultValue = "1") int page,
                      @RequestParam(value = "pageSize",defaultValue = "3")  int pageSize)
    {
        List<EbNews> ebNews= newsService.list(page,pageSize);
        model.addAttribute("ebNews",ebNews);
        model.addAttribute("curPage",page);
        model.addAttribute("maxPage",((Page)ebNews).getPages());


            return "manage/news-add";
        }

    }








